CXX=g++
CXXFLAGS= -std=c++11
CFLAGS=-g -I ../src/
LDFLAGS=-lcppunit
SRC=../src
OBJ=obj
BIN=bin

all: runtest 

.PHONY: run clean cleanall

$(OBJ)/utils.o: $(SRC)/utils.cpp $(SRC)/utils.h
	$(CXX) $(CFLAGS) -c $< -o $@

$(OBJ)/utilsTest.o: utilsTest.cpp utilsTest.h
	$(CXX) $(CFLAGS) -c $< -o $@

$(OBJ)/cs2nucl.o: $(SRC)/cs2nucl.cpp $(SRC)/cs2nucl.h
	$(CXX) $(CFLAGS) -c $< -o $@

$(OBJ)/cs2nuclTest.o: cs2nuclTest.cpp cs2nuclTest.h
	$(CXX) $(CFLAGS) -c $< -o $@

$(OBJ)/dna.o: $(SRC)/dna.cpp $(SRC)/dna.h
	$(CXX) $(CFLAGS) -c $< -o $@

$(OBJ)/assembleDna.o: $(SRC)/assembleDna.cpp $(SRC)/assembleDna.h
	$(CXX) $(CFLAGS) $(CXXFLAGS) -c $< -o $@

$(OBJ)/assembleDnaTest.o: assembleDnaTest.cpp assembleDnaTest.h
	$(CXX) $(CFLAGS) $(CXXFLAGS) -c $< -o $@

$(OBJ)/randomGenerator.o: $(SRC)/randomGenerator.cpp $(SRC)/randomGenerator.h
	$(CXX) $(CFLAGS) $(CXXFLAGS) -c $< -o $@

$(OBJ)/randomGeneratorTest.o: randomGeneratorTest.cpp randomGeneratorTest.h
	$(CXX) $(CFLAGS) $(CXXFLAGS) -c $< -o $@

$(OBJ)/histo.o: $(SRC)/histo.cpp $(SRC)/histo.h
	$(CXX) $(CFLAGS) $(CXXFLAGS) -c $< -o $@

$(OBJ)/histoTest.o: histoTest.cpp histoTest.h
	$(CXX) $(CFLAGS) $(CXXFLAGS) -c $< -o $@

$(OBJ)/sortDnaList.o: $(SRC)/sortDnaList.cpp $(SRC)/sortDnaList.h
	$(CXX) $(CFLAGS) $(CXXFLAGS) -c $< -o $@

$(OBJ)/sortDnaListTest.o: sortDnaListTest.cpp sortDnaListTest.h
	$(CXX) $(CFLAGS) $(CXXFLAGS) -c $< -o $@
	
runtest: main.cpp $(OBJ)/utils.o $(OBJ)/utilsTest.o $(OBJ)/cs2nucl.o $(OBJ)/cs2nuclTest.o $(OBJ)/dna.o \
		 $(OBJ)/assembleDna.o $(OBJ)/assembleDnaTest.o $(OBJ)/randomGenerator.o $(OBJ)/randomGeneratorTest.o \
		 $(OBJ)/histo.o $(OBJ)/histoTest.o $(OBJ)/sortDnaList.o $(OBJ)/sortDnaListTest.o
	$(CXX) $(CFLAGS) $(CXXFLAGS) $^ -o $(BIN)/$@ $(LDFLAGS)

run:
	$(BIN)/runtest
	#gnuplot ../data/plotter.gp

clean:
	rm -f $(OBJ)/*.o ../data/data

cleanall: clean
	rm -f $(BIN)/* ../data/histo.pdf
